package com.example.jixeishi1.service.impl;

import com.example.jixeishi1.dao.CollDao;
import com.example.jixeishi1.entity.cs1;
import com.example.jixeishi1.service.CollService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

@Service
public class CollServiceimpl implements CollService {

    @Autowired
    CollDao dao;

    @Override
    public PageInfo getCollection(int id,int p) {
        PageHelper.startPage(p,5);
        List list=dao.getCollection(id);
        PageInfo info=new PageInfo(list);
        int navnum[] = info.getNavigatepageNums();
        System.out.println("导航页="+ Arrays.toString(navnum));
//        System.out.println(list);
        System.out.println("总页:"+info.getPages());
        System.out.println("页:"+info.getPageNum());
        System.out.println("行:"+info.getTotal());
        System.out.println("数据:"+info.getList());
        return info;
    }

    @Override
    public int delCollection(Map map) {
        int n=dao.delCollection(map);
        return n;
    }

    @Override
    public List infopage(int id, int page) {
        cs1 cs=new cs1();
        cs.setId(id);
        cs.setPage(page);
        List list=new ArrayList();
        list.add(cs);
        return list;
    }
}
